package com.bdsc.blogs.mirror.dto;

/**
 * @author 马凯林
 */
public class JsonResponse<T> {

  public JsonResponse() {
  }

  public JsonResponse(boolean success, T result) {
    this.success = success;
    this.result = result;
  }

  public JsonResponse(boolean success, String message) {
    this.success = success;
    this.message = message;
  }

  public JsonResponse(boolean success, T result, String message) {
    this.success = success;
    this.result = result;
    this.message = message;
  }

  public JsonResponse(boolean success, T result, String message, int errorCode) {
    this.success = success;
    this.result = result;
    this.message = message;
    this.errorCode = errorCode;
  }

  public JsonResponse(boolean success, String message, int errorCode) {
    this.success = success;
    this.message = message;
    this.errorCode = errorCode;
  }

  private boolean success;
  private T result;
  private String message;
  private int errorCode;

  public boolean isSuccess() {
    return success;
  }

  public void setSuccess(boolean success) {
    this.success = success;
  }

  public T getResult() {
    return result;
  }

  public void setResult(T result) {
    this.result = result;
  }

  public String getMessage() {
    return message;
  }

  public void setMessage(String message) {
    this.message = message;
  }

  public int getErrorCode() {
    return errorCode;
  }

  public void setErrorCode(int errorCode) {
    this.errorCode = errorCode;
  }

  public static <T> JsonResponse<T> success(T result) {
    return new JsonResponse(true, result);
  }
}
